CREATE TABLE [dbo].[COMPRAS_DETALLES]
(
[ID] [numeric] (10, 0) NOT NULL,
[ID_PRODUCTO] [numeric] (10, 0) NOT NULL,
[CANTIDAD] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_Table_1_CANTIDAD] DEFAULT ((0)),
[COSTO] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_Table_1_COSTO] DEFAULT ((0)),
[COSTO_ANTERIOR] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_COMPRAS_DETALLES_COSTO_ANTERIOR] DEFAULT ((0)),
[PRECIO] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_Table_1_PRECIO] DEFAULT ((0)),
[PRECIO_ANTERIOR] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_COMPRAS_DETALLES_PRECIO_ANTERIOR] DEFAULT ((0)),
[DESCUENTO] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_Table_1_DESCUENTO] DEFAULT ((0)),
[X_DESCUENTO] [numeric] (10, 4) NOT NULL CONSTRAINT [DF_Table_1_X_DESCUENTO] DEFAULT ((0)),
[IMPUESTO] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_Table_1_IMPUESTO] DEFAULT ((0)),
[X_IMPUESTO] [numeric] (10, 4) NOT NULL CONSTRAINT [DF_Table_1_X_IMPUESTO] DEFAULT ((0)),
[C_DEVUELTA] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_Table_1_C_DEVUELTA] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[COMPRAS_DETALLES] ADD CONSTRAINT [PK_Table_1] PRIMARY KEY CLUSTERED  ([ID], [ID_PRODUCTO]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[COMPRAS_DETALLES] ADD CONSTRAINT [FK_COMPRAS_DETALLES_COMPRAS] FOREIGN KEY ([ID]) REFERENCES [dbo].[COMPRAS] ([ID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[COMPRAS_DETALLES] ADD CONSTRAINT [FK_COMPRAS_DETALLES_PRODUCTOS] FOREIGN KEY ([ID_PRODUCTO]) REFERENCES [dbo].[PRODUCTOS] ([ID])
GO
